#pragma once

#include <assert.h>
#include <vector>



namespace ann
{

typedef std::vector<double> dVec;
typedef unsigned int UINT;

class WMatrix
{
public:
    WMatrix( const unsigned int p_upCnt, const unsigned int p_dwCnt );

	virtual ~WMatrix(void);

public:
    inline  void    SetValue( const unsigned int p_upIdx,
                              const unsigned p_dwIdx,
                              const double p_newValue ) const
            {
                assert( p_upIdx<m_upCnt && p_dwIdx<m_dwCnt );
                m_weight[p_upIdx*m_upCnt + p_dwIdx] = p_newValue;
            }

    inline  double  GetValue( const unsigned int p_upIdx,
                              const unsigned p_dwIdx ) const
            {
                assert( p_upIdx<m_upCnt && p_dwIdx<m_dwCnt );
                return m_weight[p_upIdx*m_upCnt + p_dwIdx];
            }

    inline  UINT    GetDimUp( void ) const
            {
                return m_upCnt;
            }

    inline  UINT    GetDimDw( void ) const
            {
                return m_dwCnt;
            }

    inline  double& operator[]( const unsigned int p_idx ) const
            { 
                assert( p_idx < m_upCnt*m_dwCnt );
                return m_weight[p_idx]; 
            }

    inline  double& operator()( const unsigned int p_upIdx,
                                const unsigned int p_dwIdx ) const
            { 
                assert( p_upIdx<m_upCnt && p_dwIdx<m_dwCnt );
                return m_weight[p_upIdx*m_upCnt + p_dwIdx]; 
            }

            dVec&   operator*( const dVec& p_Vec ) const ;

            // col from 1..m_dwCnt
            dVec&   GetCol( const unsigned int p_col ) const;

private:
    UINT    m_upCnt;
    UINT    m_dwCnt;

    double* m_weight;
};

}

